﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebCrawler.HttpConnection;

namespace WebCrawler.Crawler
{
    class Program
    {
        static void Main(string[] args)
        {
            //Crawler c = new Crawler("http://public.ucn.dk/fen/testsite/", 3);

            //Console.WriteLine("*** Downloading pages and Building Sitemap ***\n");
            //c.BuildSiteMapTest321();
            //Console.WriteLine("\n\n*** Traversing Sitemap ***\n");
            //c.GraphTraversal();

            SecondCrawler crawler = new SecondCrawler("http://www.google.dk");
            crawler.BuildSiteMap();

            foreach (var item in crawler.Graph.VerticesAsList())
            {
                Console.WriteLine("Node: {0}, Edges: {1}, Level: {2}", item.Url, item.Edges.Count, item.level);
            }

            //SocketTest("http://public.ucn.dk/fen/testsite/");
            //TcpTest("http://public.ucn.dk/fen/testsite/");

            Console.WriteLine("Done");
            Console.ReadLine();
        }

        static void SocketTest(string url)
        {
            HttpSocket socket = new HttpSocket();
            string page = socket.Receive(url);
            Console.WriteLine(page);
        }

        static void TcpTest(string url)
        {
            HttpTcpClient client = new HttpTcpClient();
            string page = client.Receive(url);
            Console.WriteLine(page);
        }
    }
}
